package com.ls.pattern.establish.factory.simple;

import com.ls.pattern.establish.factory.pizza.CheesePizza;
import com.ls.pattern.establish.factory.pizza.GreekPizza;
import com.ls.pattern.establish.factory.pizza.Pizza;

//简单工厂
public class SimpleFactory {

    public Pizza createPizza(String orderType) {
        System.out.println("使用简单工厂模式");
        Pizza pizza = null;
        if (orderType.equals("greek")) {
            pizza = new GreekPizza();
            System.out.println("使用 greek");
        } else if (orderType.equals("cheese")) {
            pizza= new CheesePizza();
            System.out.println("使用 cheese");
        } else {

        }
        return pizza;
    }
    //静态工厂
    public static Pizza createPizza2(String orderType) {
        System.out.println("使用简单静态工厂模式");
        Pizza pizza = null;
        if (orderType.equals("greek")) {
            pizza = new GreekPizza();
            System.out.println("使用 greek");
        } else if (orderType.equals("cheese")) {
            pizza= new CheesePizza();
            System.out.println("使用 cheese");
        } else {

        }
        return pizza;
    }
}
